Skip Headers
Oracle® Enterprise Manager Command Line Interface
12c Release 1 (12.1.0.3)

Part Number E17786-08
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
PDF · Mobi · ePub

2 Downloading and Deploying EM CLI

This chapter discusses the following Enterprise Manager Command Line Interface (EM CLI) topics:

Downloading and Deploying the EM CLI Client

The EM CLI OMS is automatically installed with the OMS, but you must download and set up the client portion. The following instructions cover download procedures for the EM CLI client. The client kits are available for public access, so do not require authentication.

As mentioned in Chapter 1, the EM CLI client features two kits: EM CLI Standard and EM CLI with the Script option. The EM CLI Script option includes the Jython Interpreter for advanced script support (described in Chapter 3), as well as all of the features present in the EM CLI Standard kit.

The following sections explain how to download and deploy these two kits.

Requirements

Before downloading the EM CLI client, ensure that the following system requirements have been met:

  • Enterprise Manager 12c Cloud Control framework

  • Java version 1.6.0_43 or greater

  • Workstation running Solaris, Linux, HPUX, Tru64, AIX, or Windows with NTFS

Downloading and Deploying the Client for Standard EM CLI

To download the client for standard EM CLI only:

  1. Obtain the standard EM CLI client kit emclikit.jar using one of the following methods:

    • Download this kit from any 12c Cloud Control installation at the following location:

      /em/public_lib_download/emcli/kit/emclikit.jar
      
    • Download this kit from the Cloud Control console:

      • From the Setup menu, select Command Line Interface.

      • In the EM CLI Standard section, click the Download the EM CLI Standard Kit to your workstation link.

  2. Enter the following command to ensure that you have the correct Java in your PATH:

    which java
    

    This should show the Java in $JAVA_HOME/bin.

  3. Set your JAVA_HOME environment variable and ensure that it is part of your PATH. You must be running Java 1.6.0_43 or greater. For example:

    setenv JAVA_HOME /usr/local/packages/j2sdk1.6.0_43
    
    setenv PATH $JAVA_HOME/bin:$PATH
    
  4. Install the standard EM CLI kit in any directory either on the same system as the OMS or on any system in your network (download the emclikit.jar file to that system):

    java -jar emclikit.jar client -install_dir=<emcli_client_dir>
    

    The EM CLI client is installed in <emcli_client_dir>.

  5. Execute emcli help setup from the EM CLI home (the directory where you have installed EM CLI) for instructions on how to use the setup verb to configure the client for a particular OMS.

Downloading and Deploying the Client with the Script Option

To download the client for standard EM CLI as well as Interactive and Script EM CLI:

  1. Obtain the EM CLI client kit emcliadvancedkit.jar using one of the following methods:

    • Download this kit from any 12c Cloud Control installation at the following location:

      https://your_em_host:port/em/public_lib_download/emcli/kit/
      
    • Download this kit from the Cloud Control console:

      • From the Setup menu, select Command Line Interface.

      • In the EM CLI with Script Option section, click the Download the EM CLI with Script option kit to your workstation link.

  2. Enter the following command to ensure that you have the correct Java in your PATH:

    which java
    

    This should show the Java in $JAVA_HOME/bin.

  3. Set your JAVA_HOME environment variable and ensure that it is part of your PATH. You must be running Java 1.6.0_43 or greater. For example:

    setenv JAVA_HOME /usr/local/packages/j2sdk1.6.0_43
    
    setenv PATH $JAVA_HOME/bin:$PATH
    
  4. Install the advanced EM CLI kit in any directory either on the same system as the OMS or an any system in your network (download the emcliadvancedkit.jar file to that system):

    java -jar emcliadvancedkit.jar client -install_dir=<emcli_client_dir>
    
    

    The EM CLI client is installed in <emcli_client_dir>.

  5. Execute emcli help sync from the EM CLI home (the directory where you have installed EM CLI) for instructions on how to use the sync verb to configure the client for a particular OMS.

    Sync establishes communication with the OMS and ensures that the OMS and all information associated with it are available through the CLI.

Note:

By default, advanced EM CLI does not store any user session information on disk. It is tailored to build production-grade Jython modules for Enterprise Manager.

Getting Started with EM CLI

After the EM CLI client is downloaded and installed, you are ready to begin using EM CLI. At this point, you can run the EM CLI client out of the installation directory location, or alternatively, you can add it to your PATH.

Using Basic Operational Verbs

Immediately after installation, only basic operational verbs are available:

  • argfile — Execute an EM CLI verb where the verb and any options are contained in a file.

  • help — Access command-line help for EM CLI verbs.

  • login — Log in and establish a session with the OMS.

  • logout — Log out of EM CLI client from Enterprise Manager.

  • setup — Configure EM CLI to function with a specific OMS.

    (See Connecting the EM CLI Client to OMS for important information about this verb.

  • status — Show EM CLI setup details

  • sync — Synchronize the EM CLI client with an OMS.

  • version — List EM CLI verb versions or the EM CLI client version.

EM CLI incorporates a comprehensive command-line help system that provides various levels of assistance. Available from any EM CLI client installation, the help system provides a listing of all available verbs, descriptive overviews for each verb, syntax, as well as usage examples. The command-line help is the definitive EM CLI information source.

Using Commands in Standard Mode

To access command-line help, for instance, in standard mode, enter the following command for an overview of all available verbs:

./emcli help

Alternatively, enter the same command followed by the verb name to view a detailed verb description, the verb parameters and options, and usage examples, as in:

./emcli help login

Calling Commands in Script and Interactive Modes

To access command-line help for Interactive mode, for instance, you must first invoke the EM CLI command prompt:

$>./emcli

To access help for all verbs, call the verb name followed by parentheses:

emcli> help()

To find help for a specific verb, call the help command with the verb within the parentheses surrounded by a single quote:

emcli>help('login')

Note:

The setup and sync commands are not available inside Script and Interactive modes.

Tip:

read the readme.txt file shipped with the advanced kit for more specific examples on how to call the verbs in the EM CLI Client in Script and Interactive modes.

Connecting the EM CLI Client to OMS

You must run the setup verb to connect the EM CLI client to the OMS running the EM CLI Management Services. Running setup installs all available verb-associated command-line help from the EM CLI Management Service. If you have installed EMCLI with the Script option, you can use the sync command instead of the setup command.

Note:

If you have followed the instructions in Downloading and Deploying the EM CLI Client, the set up is already done for you.

You can use one EM CLI client installation to function with multiple OMSes. However, at any time, EM CLI can function with a particular OMS. For either scenario, you need to set up the EM CLI client once for each OMS. You also need to subsequently set the EMCLI_STATE_DIR environment variable to the directory that was specified as the client directory for the particular OMS.

To connect the EM CLI client to OMS:

  1. Understand the syntax of the setup and sync verbs and their options by entering the following commands or referring to the respective verbs in Chapter 4, "Verb Reference":

    • Command-line EM CLI:

      ./emcli help setup
      
    • Script and Interactive EM CLI:

      ./emcli help sync
      
  2. Enter the setup verb with at least the minimally required parameters as shown in the following examples:

    • Command-line EM CLI:

      ./emcli setup -url=http://myworkstation.example.com:em_port/em    -username=em_user
      
    • Script and Interactive EM CLI:

      ./emcli sync -url=http://myworkstation.example.com:em_port/em    -username=em_user -trustall
      

      If you have already downloaded certificates, you can specify them using the environment variable EMCLI_CERT_LOC. In this case, the -trustall option is not needed.

    Note:

    Specify the URL you are using to log in to Enterprise Manager through the browser.

    As you observed from step 1, the setup verb has several options, including the following important options:

    • -autologin

    • -noautologin

    In autologin mode, if a session times out, EM CLI automatically logs you in. In the default noautologin mode, if no EM CLI command executes within the 45-minute default session time-out period, you need to log in using the login verb to be able to execute the verbs.

  3. Enter your user password for Enterprise Manager when prompted after the EM CLI client connects with the EM CLI Management Services.

After running the setup verb, the message "Emcli Setup Successful" appears, and you are ready to begin using EM CLI.

Tip:

For complete information on the setup verb and its options, including autogin and noautologin referenced in step 2, see the setup verb.

To configure the EM CLI client to function with multiple Oracle Management Services by implementing multiple setups, see the Examples section for the setup verb.

Configuring an HTTP Proxy Environment

If you are planning to use EM CLI through an HTTP proxy server, you need to set an additional environment variable, EMCLI_OPTS, that supplies EM CLI with the requisite proxy host and port information. The following examples illustrate setting the EMCLI_OPTS environment variable for both Windows and UNIX operating systems.

Example 2-1 Setting EMCLI_OPTS in a Microsoft Windows Environment

>set EMCLI_OPTS=-Dhttp.proxyHost=<proxy host> -Dhttp.proxyPort=<proxy port>

Example 2-2 Setting EMCLI_OPTS in a UNIX Environment (TCSH)

>setenv EMCLI_OPTS "-Dhttp.proxyHost=<proxy host> -Dhttp.proxyPort=<proxy port>"

Configuring Log File Settings for EM CLI

EM CLI creates log files to record informational and error messages generated during operation. Not all of the logs in the following examples are necessarily present. Logs are created as needed and are appended — they are preserved between invocations of EM CLI. You can safely delete log files any time without affecting the EM CLI operation. The logs will help you troubleshoot any run-time errors.

The following examples show possible log file locations:

<EM_CLI_Instance_Home>/.emcli.log
<EM_CLI_Instance_Home>/.emcli.log.1

<EM_CLI_Instance_Home> refers to the directory specified by the -dir option in the latest running of the setup verb (with an appended .emcli sub-directory). The current <EM_CLI_Instance_Home> directory can be identified by executing the status verb to display the setup summary.

Log files are limited to a maximum of 0.5 MB. EM CLI alternates between the two log files — as each file reaches the 0.5 MB limit, EM CLI begins writing to the other file, overwriting the oldest log file after emcli.log.1 has been filled for the first time.

Log File Locations

The following examples show possible log file locations:

Example 2-3 No Configuration Directory Specified with Setup Verb (default location)

user.home/.emcli/.emcli.log
user.home/.emcli/.emcli.log.1

If you do not specify a configuration directory when you run the setup verb (-dir option is omitted), EM CLI assumes the .emcli configuration directory is located within your local home directory. The log files are placed at the root level of the .emcli directory. The .emcli directory must be local (not mounted remotely).

Example 2-4 Local Configuration Directory Specified with Setup Verb (-dir=<local directory>

local.dir/.emcli/.emcli.log
local.dir/.emcli/.emcli.log.1

In this example, the configuration directory is specified using the -dir option when the setup verb is run. This allows you to specify a local configuration directory if the user home directory is mounted remotely (through NFS, for example).

Log File Location and Log Level

You can specify the log file directory and the log level, if desired, using the following variables, which you can set as environment variables:

  • EMCLI_LOG_LOC — Sets the log file directory to any desired location.

  • EMCLI_LOG_LEVEL — Presets the log level. Allowed values are:

    • SEVERE (default)

    • INFO

    • FINE

    • FINER

    • FINEST

    • ALL

Security and Authentication

To enable EM CLI to function with a particular OMS, configure EM CLI by executing the setup verb. This is a one-time operation for this particular OMS.

Example 2-5 CLI-Enterprise Manager Authentication

>emcli setup –url="http[s]://host:port/em" –username="<username>"  [-trustall] [-novalidate]>please enter password: 

You can find out the OMS connection information from any EM CLI client by invoking the setup verb without any options. For example:

$ emcli setup
Oracle Enterprise Manager Cloud Control 12c Release 2.
Copyright (c) 1996, 2012 Oracle Corporation and/or its affiliates. All rights reserved.
 
Instance Home          : /private/emcli/setup/.emcli
Verb Jars Home         : /private/emcli/setup/.emcli
EM URL                 : https://myomshost.us.oracle.com:5416/em
EM user                : user1
Trust all certificates : true
Auto login             : false

You can also invoke the status command, which provides more information than the setup command:

$ emcli status
Oracle Enterprise Manager Cloud Control 12c Release 2.
Copyright (c) 1996, 2012 Oracle Corporation and/or its affiliates. All rights reserved.
 
Instance Home          : /private/emcli/setup/.emcli
Verb Jars Home         : /private/emcli/setup/.emcli
Status                 : Configured
EMCLI Home             : /private/MWHome/oms/bin
EMCLI Version          : 12.1.0.2.0
Java Home              : /private/MWHome/jdk16/jdk
Java Version           : 1.6.0_24
Log file               : /private/emcli/setup/.emcli/.emcli.log
EM URL                 : https://myomshost.us.oracle.com:5416/em
EM user                : sysman
Auto login             : false
Trust all certificates : true

HTTPS Trusted Certificate Management

For authenticating an OMS during the SSL server authentication phase of an HTTPS connection handshake, EM CLI searches for trusted certificates in the following key stores:

CONFIG_DIR/.emcli/.localkeystore
user.home/.emcli/.keystore
JRE_HOME/lib/security/cacerts

CONFIG_DIR is the directory specified by the -dir option in the latest running of the setup verb (with an appended .emcli sub-directory).

JRE_HOME in a JDK installation is typically JAVA_HOME/jre.

The JDK keytool command can manage the key stores. For more information about this tool, see the security documentation for your Java VM installation, or at the time of this writing:

http://java.sun.com/j2se/1.5.0/docs/tooldocs/solaris/keytool.html

Not all of the key stores in the list above will necessarily be present.

Secure Clients

You can provide credentials to EM CLI in one of two ways:

  • Provide credentials at the time of use. See the login and logout verbs for information on credentials.

  • Make credentials persistent on the host system where the EM CLI client is running, as might be the case when executing EM CLI verbs from a shell script.

Caution:

You should only persist credentials on hosts when the host is a secure client, since the only protection available for credentials is the file-system security of the OS.

Oracle also recommends not using persistent credentials if the EM CLI user's home directory is mounted over NFS or any other insecure file system.

Secure Mode for the EM CLI Setup

The EM CLI client installs certain configuration files and a client-side implementation of verbs on the client system. The EM CLI client configuration files contain information such as the OMS URL, Enterprise Manager user names, and Enterprise Manager passwords.

By default, the EM CLI client is set up in secure mode. In this mode, EM CLI does not store any Enterprise Manager or SSO passwords on the client disk. The command emcli setup -noautologin sets up the EM CLI client in secure mode. By default, -noautologin is true. Therefore, you do not need to specify it if you want to set up the EM CLI client in secure mode. In secure mode, if the EM CLI session times out due to inactivity, explicit login (using the login verb) is required before invoking any verb.

If you want to set up EM CLI in the insecure auto-login mode, you can use the emcli setup -autologin command. In this mode, if an EM CLI session times out due to inactivity, EM CLI automatically re-establishes the session when a verb needs to execute. However, if you explicitly logged out by running emcli logout, you need to explicitly log in again using emcli login.

  • For information on the -noautologin option, see the setup verb on page 4-461.

  • For information on logging in, see the login verb on page 4-342.

  • For information on logging out, see the logout verb on page 4-343.

Format Option Availability for Output Data Verbs

Note:

The following inforation regarding the -script option is not to be confused with the Script mode.

For easy parsing of verb output by scripts, a script option is available for all verbs that generate output data. If you use the -script option, all output columns become tab-separated (with non-null values), and all rows become newline-separated. You can override the default column and row separators by using the -format option in place of -script.

[-script|-format="name:<format type>;column_separator:<separator_text>;row_separator:<separator_text>"]

Supported -format options are shown in Table 2–1.

Table 2-1 Supported "-format" Options

Option Explanation

-format="name:pretty"

Pretty-print the output. This is the default when both -script and -format are not specified.

-format="name:script"

Identical to just specifying –script. Columns are tab-separated, and rows are newline-separated.

-format="name:script;column_separator:<column_sep_string>"

Causes the verb output to be column-separated by <column_sep_string>. Rows are separated by the newline character.

-format="name:script;row_separator:<row_sep_string>"

Causes the verb output to be row-separated by <row_sep_string>. Columns are separated by the tab character.

-format="name:script;column_separator:<column_sep_string>;row_separator:<row_sep_string>"

Causes the verb output to be column-separated by <column_sep_string> and row- separated by <row_sep_string>.

-format="name:csv"

Produces a table with the columns separated by commas and the rows by newlines.